package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ParameterOrder;
import com.ruoyi.system.service.IParameterOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单参数管理Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/system/parameterorder")
public class ParameterOrderController extends BaseController
{
    @Autowired
    private IParameterOrderService parameterOrderService;

    /**
     * 查询订单参数管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParameterOrder parameterOrder)
    {
        startPage();
        List<ParameterOrder> list = parameterOrderService.selectParameterOrderList(parameterOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单参数管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:order:export')")
    @Log(title = "订单参数管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ParameterOrder parameterOrder)
    {
        List<ParameterOrder> list = parameterOrderService.selectParameterOrderList(parameterOrder);
        ExcelUtil<ParameterOrder> util = new ExcelUtil<ParameterOrder>(ParameterOrder.class);
        return util.exportExcel(list, "订单参数管理数据");
    }

    /**
     * 获取订单参数管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:order:query')")
    @GetMapping(value = "/{parameterOrderId}")
    public AjaxResult getInfo(@PathVariable("parameterOrderId") Long parameterOrderId)
    {
        return AjaxResult.success(parameterOrderService.selectParameterOrderById(parameterOrderId));
    }

    /**
     * 新增订单参数管理
     */
    @PreAuthorize("@ss.hasPermi('system:order:add')")
    @Log(title = "订单参数管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParameterOrder parameterOrder)
    {
        return toAjax(parameterOrderService.insertParameterOrder(parameterOrder));
    }

    /**
     * 修改订单参数管理
     */
    @PreAuthorize("@ss.hasPermi('system:order:edit')")
    @Log(title = "订单参数管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParameterOrder parameterOrder)
    {
        return toAjax(parameterOrderService.updateParameterOrder(parameterOrder));
    }

    /**
     * 删除订单参数管理
     */
    @PreAuthorize("@ss.hasPermi('system:order:remove')")
    @Log(title = "订单参数管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parameterOrderIds}")
    public AjaxResult remove(@PathVariable Long[] parameterOrderIds)
    {
        return toAjax(parameterOrderService.deleteParameterOrderByIds(parameterOrderIds));
    }
}
